package com.itshizhan.itjidancideveloper.dao;

import com.itshizhan.itjidancideveloper.models.Article;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface ArticleDao extends JpaRepository<Article,Integer>, JpaSpecificationExecutor<Article> {
	@Query(value = "SELECT * from article where category_id =?1 and state = 1",
			countQuery = "select count(*) from article where category_id =?1 and state = 1",
			nativeQuery = true)
	Page<Article> findByCategoryId(String categoryId, PageRequest pageable);
}
